package com.gxa.web_admin.controller.kk;

import com.gxa.common.base.RespResult;
import com.gxa.modules.client.BaiduMap;
import com.gxa.modules.client.Weather;
import com.gxa.modules.dto.WeatherDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Autowired
    private BaiduMap baiduMap;
    @Autowired
    private Weather weather;

    @RequestMapping(value = "/weathers",method = RequestMethod.GET)
    public RespResult location(HttpServletRequest request){
        //获取ip
        String ip=request.getRemoteAddr();
        System.out.println(ip);
        String address=baiduMap.getAddress(ip);
        System.out.println(address);
        WeatherDTO weathers= weather.getWeather(address);
        System.out.println(weathers);
         return RespResult.success(weathers);
    }
}
